<?php

namespace App\Admin\Actions\Grid;

use App\Models\Customer;
use Dcat\Admin\Grid\BatchAction;
use Dcat\Admin\Widgets\Modal;
use Dcat\Admin\Http\JsonResponse;

class CustomerBatchOoaInto extends BatchAction
{
    /**
     * @return string
     */
	protected $title = '返回公海';

    public function handle($input)
    {
        $ids = $input['_key'];
        Customer::ooaInto($ids);
        return JsonResponse::make()->success('操作成功')->refresh();
    }

    public function confirm()
    {
        return ['您确定要退回公海吗？', ''];
    }

    protected function getModalScript()
    {
        // 弹窗加载后往ids隐藏域写入批量选中的行ID
        return <<<JS
        // 获取选中的ID数组
        var key = {$this->getSelectedKeysScript()}
        $('#ids').val(key);
JS;
    }


}
